<template>
  <BasicModal v-bind="$attrs" @register="registerModal" :title="title" :width="800" @ok="handleSubmit">
    <nurse-service-personnel-assign-form ref="formComponent" :formDisabled="formDisabled" :formBpm="false"
      @success="submitSuccess"></nurse-service-personnel-assign-form>
  </BasicModal>
</template>

<script lang="ts">
import { ref, } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import NurseServicePersonnelAssignForm from './NurseServicePersonnelAssignForm.vue';

export default {
  name: "ServicePersonnelAssignModal",
  components: {
    BasicModal,
    NurseServicePersonnelAssignForm
  },
  emits: ['register', 'success'],
  setup(_p, { emit }) {
    const formComponent = ref()
    const isUpdate = ref(true);
    const formDisabled = ref(false);
    const title = ref('')

    //表单赋值
    const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
      setModalProps({ defaultFullscreen: false, confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
      isUpdate.value = !!data?.isUpdate;
      title.value = '分配订单'
      formDisabled.value = !data?.showFooter;
      formComponent.value.edit(data.record)
    });

    function handleSubmit() {
      formComponent.value.submitForm();
    }

    function submitSuccess() {
      emit('success');
      closeModal();
    }

    return {
      registerModal,
      title,
      formComponent,
      formDisabled,
      handleSubmit,
      submitSuccess
    }
  }
}
</script>
<style lang="less" scoped>
/** 时间和数字输入框样式 */
:deep(.ant-input-number) {
  width: 100%
}

:deep(.ant-calendar-picker) {
  width: 100%
}
</style>
